package Math01;

public class ErFen {
    public static void main(String[] args) {
        int[] arr={1,2,3,4,5,6,7,8};
        int num=3;
       int result= FindShu( arr,num);
        System.out.println(result);
    }

    private static int FindShu(int[] arr, int num) {
        int min=0;
        int max=arr.length-1;
        while (min<=max){
            int mid=(min+max)>>1;
            if(arr[mid]>num){
                max=mid-1;
            }else if(arr[mid]<num){
                min=mid+1;
            }else
                return mid;
        }

    return -1;
    }

}
